package com.bum.api.core.bo.om;

import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.math.RandomUtils;

public enum Client {
	// Ola Android APK
	OlaApk("77B9A513", "Ola APK", "12"),

	// Ola iPhone
	OlaIphone("F57C1E6A", "Ola iPhone", "11"),

	// Ola Window Phone
	OlaWinPhone("8052CCDA", "Ola Win Phone", "15"),

	// Load Json, dùng User Agent riêng
	JsonFetcher("0B981071", "JSON Fetcher", "0"),

	// ApiAjax("5EDFCBA3", "API Ajax"),

	OlaMeWeb("02BE61B0", "Ola Me Web", "0"),

	// HomeDesktop("7D181BC0", "Home Desktop"),

	// Chỉ hoạt động với Debug Mode
	WebTest("FCBA35ED", "Web Test", "0"),

	// Bắn cá APK
	FishootApk("0D05EC5C", "Bắn cá APK", "12"),
	FishootIphone("5B1208C7", "Bắn cá iPhone", "11"),
	FishootJ2me("D77C9B1D", "Bắn cá J2ME", "0");

	static final HashMap<String, Client>	CODES;
	static {
		CODES = new HashMap<String, Client>();
		for (Client client : Client.values()) {
			CODES.put(client.code, client);
		}
	}

	public static Client get(String code) {
		return CODES.get(code);
	}

	private Client(String code, String name, String device) {
		this.code = code;
		this.name = name;
		this.device = device;
	}

	public final String	code;
	public final String	name;
	public final String	device;

	static Set<String>	GAME_CLIENTS	= new HashSet<String>(Arrays.asList(FishootApk.code, FishootIphone.code));

	public static boolean isGameClient(String cid) {
		return GAME_CLIENTS.contains(cid);
	}

	public static void main(String[] args) {
		String code = DigestUtils.md5Hex("Bắn cá J2ME" + System.currentTimeMillis() + " " + RandomUtils.nextFloat()).substring(8, 16).toUpperCase();
		System.out.println(code);

//		String client = "02BE61B0";
//		client = Base64.encodeBase64String(client.getBytes());
//		System.out.println(client);
	}
}
